    const  fs = require('fs')
    const path = require('path')
    

    function render(url,status=200,res){ //python js 默认值语法，就是在形参上加个赋值语句

        res.writeHead(200, {
            "content-type": "text/html; charset=utf-8"
        })
        fs.readFile(path.join(__dirname, url), 'utf-8', (err, data) => {
            if (err) {
                console.log(err)
            } else {
                res.end(data)
            }
        })
    }
    function router(url, res) {
    
    if (url === '/home') {
      render('./static/home.html',res)
    } else if (url === '/login') {
    render('./static/login.html',res)
    } else {
       render('./static/404.html',res,404)
    }
}
module.exports = router